package com.bdqn.mzc.service.impl;

import com.bdqn.mzc.mapper.RegionMapper;
import com.bdqn.mzc.mapper.ScenicspotMapper;
import com.bdqn.mzc.mapper.ValuateMapper;
import com.bdqn.mzc.model.Region;
import com.bdqn.mzc.model.Scenicspot;
import com.bdqn.mzc.model.Valuate;
import com.bdqn.mzc.service.ShowInfoService;
import com.bdqn.mzc.vo.NutriVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShowInfoServiceImpl implements ShowInfoService {

    @Autowired
    private RegionMapper regionMapper;

    @Autowired
    private ScenicspotMapper scenicspotMapper;

    @Autowired
    private ValuateMapper valuateMapper;

    @Override
    public List<Region> homeProvinceShow() {
        return regionMapper.selectRegionAll();
    }

    @Override
    public List<Region> homeProvinceShow(NutriVo nutriVo) {
       return regionMapper.selectRegionAll(nutriVo);
    }

    @Override
    public Region selectByPrimaryKey(Integer regionId) {
        return regionMapper.selectByPrimaryKey(regionId);
    }

    @Override
    public int updateByPrimaryKeySelective(Region record) {
        return regionMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int insertSelective(Region record) {
        return regionMapper.insert(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer regionId) {
        return regionMapper.deleteByPrimaryKey(regionId);
    }

    @Override
    public int homeSumScenicsPot() {
        return scenicspotMapper.sumScenicsPot();
    }

    @Override
    public List<Scenicspot> homeOrderQuantityShow() {
        return scenicspotMapper.selectScenicsPotByorderQuantity();
    }

    @Override
    public List<Scenicspot> homeGradeShow() {
        return scenicspotMapper.selectScenicsPotByGrade();
    }


    @Override
    public List<Scenicspot> tripSelectScenicsPotByUnknown(String[] regionid, String[] scenicspotgrade, String[] scenicspotaddress, String[] scenicspotimgscore, String[] scenicspotordersquantity, String[] scenicspotprice, String[] scenicspotopentime) {
        if (scenicspotopentime!=null&&scenicspotopentime.length>0){
            if ("100".equals(scenicspotopentime[0])){
                scenicspotopentime[0]="%全天营业%";
            }
        }
        return scenicspotMapper.selectScenicsPotByUnknown(regionid, scenicspotgrade, scenicspotaddress, scenicspotimgscore, scenicspotordersquantity, scenicspotprice, scenicspotopentime);
    }

    @Override
    public List<Scenicspot> tripSlectScenicspotByNameLink(String scenicspotscenicname) {
        return scenicspotMapper.slectScenicspotByNameLink(scenicspotscenicname);
    }

    public Scenicspot selectScenicspotById(Integer id){
        return scenicspotMapper.selectScenicspotById(id);
    }

    @Override
    public List<Valuate> selectValuateByScenicspotId(Integer scenicspotId) {
        return valuateMapper.selectValuateByScenicspotId(scenicspotId);
    }
}
